package dltec.job;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

public class job03 {
	
	/**
	 * •1.创建Person类，包含属性：身份证号、姓名、年龄；
•	2.创建四个对象，把四个对象存入到list集合；
•	3.对四个对象分别根据年龄和身份证号进行单独排序；

	 * @param args
	 */

	public static void main(String[] args) {
		
		Person[] list = {new Person("张三","004",49),new Person("李四","003",36),new Person("王五","002",29),new Person("赵六","001",58)};
		
		Arrays.sort(list,new Comparator<Person>() {

			@Override
			public int compare(Person o1, Person o2) {
				/*if(o1.getIDcard() > o2.getIDcard()){
					return 1;
				}else if(o1.getIDcard() < o2.getIDcard()){
					return -1;
				}else return 0;*/
				return o1.getIDcard().compareTo( o2.getIDcard());
			}
		});
		
		System.out.println(Arrays.toString(list));
		
		System.out.println("");
		
		Arrays.sort(list,new Comparator<Person>() {

			@Override
			public int compare(Person o1, Person o2) {
				
				return o1.getAge() - o2.getAge();
			}
		});
		
		System.out.println(Arrays.toString(list));

	}

}
